# exceptions.py
from typing import Optional


class BrowserOperationError(Exception):
    """浏览器基础操作异常基类"""
    def __init__(self, message: str, context_id: Optional[str] = None):
        super().__init__(message)
        self.context_id = context_id

class PageTimeoutError(BrowserOperationError):
    """页面操作超时异常"""
    pass

class ResourceLoadError(BrowserOperationError):
    """资源加载失败异常"""
    def __init__(self, url: str, context_id: Optional[str] = None):
        super().__init__(f"Failed to load resource: {url}", context_id)
        self.url = url


class CallbackError(Exception):
    """
    回调异常处理
    """
    def __init__(self, message: str):
        super().__init__(message)


class OperationTimeoutError(Exception):
    pass


class PageOperationError(Exception):
    pass


class WorkstationError(Exception):
    pass